/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helpers;

/**
 *
 * @author arnaldo
 */
public class MyPolygon {
    private MyPoint [] points;
    
    public MyPolygon(MyPoint [] points){
        this.points = points;
    }

    public static MyPolygon randomPolygon(){

        MyPoint [] points = new MyPoint[4];
        points[0] = RandomGenerator.Location();
        points[1] = RandomGenerator.Location();
        points[2] = RandomGenerator.Location();
        points[3] = RandomGenerator.Location();

        MyPolygon p = new MyPolygon(points);

        return p;
    }

    @Override
    public String toString(){
        String s = "POLYGON((";

        for(int i=0;i<this.points.length;i++){
            s += this.points[i].points() + ", ";
        }

        s += this.points[0].points() + "))";

        return s;
    }

    public String forPostgre(){
        String s = "(";

        for(int i=0;i<this.points.length;i++){
            s += this.points[i].postgrel() + ", ";
        }

        s += this.points[0].postgrel() + ")";

        return s;
    }
 
}
